/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package service;

import com.openbrew.openbrewrf.SalesOrder;
import com.openbrew.openbrewrf.SimpleSalesOrder;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

/**
 *
 * @author chapmand
 */
@Stateless
@Path("com.openbrew.openbrewrf.simplesalesorder")
public class SimpleSalesOrderFacadeREST extends AbstractFacade<SimpleSalesOrder>  {
    @PersistenceContext(unitName = "com.openBrew_openBrewRF_war_1.0PU")
    private EntityManager em;

    public SimpleSalesOrderFacadeREST() {
        super(SimpleSalesOrder.class);
    } 
    
    @GET
    @Override
    @Produces({"application/xml", "application/json"})
    public List<SimpleSalesOrder> findAll() {
        return super.findAll();
    }

    @GET
    @Path("{from}/{to}")
    @Produces({"application/xml", "application/json"})
    public List<SimpleSalesOrder> findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) {
        return super.findRange(new int[]{from, to});
    }

    @GET
    @Path("namedQueryRange/{from}/{to}/{str}/{id}")
    @Produces({"application/xml", "application/json"})
    public List<SimpleSalesOrder> findNamedQueryRange(@PathParam("from") Integer from
            , @PathParam("to") Integer to, @PathParam("str") String str
            , @PathParam("id") Integer id) {
        return super.findNamedQueryRange(new int[]{from, to}, str, id);
    }
    
    @GET
    @Path("runNamedQueryWithID/{str}/{id}")
    @Override
    @Produces({"application/xml", "application/json"})
    public List<SimpleSalesOrder> runNamedQueryWithID(@PathParam("str") String str
            , @PathParam("id") int id){
        return super.runNamedQueryWithID(str, id);
    }

    @GET
    @Path("namedQueryCount/{str}/{id}")
    @Produces("text/plain")
    public String namedQueryCount(@PathParam("str") String str
            , @PathParam("id") Integer id) {
        return String.valueOf(super.namedQueryCount(str, id, "cId"));
    }

    @GET
    @Path("count")
    @Produces("text/plain")
    public String countREST() {
        return String.valueOf(super.count());
    }

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }
}
